using Contrib.Mod.AccountWidgets.Models;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;
using System;
using Orchard.Environment.Extensions;
using Orchard;
namespace Contrib.Mod.AccountWidgets
{
    [OrchardFeature("Contrib.Mod.AccountWidgets.LoginWidgets")]
    public class LoginWidgetMigrations : DataMigrationImpl
    {
        public LoginWidgetMigrations(IOrchardServices services) 
        {
            this.Services = services;
        }

        public IOrchardServices Services { get; set; }

        public int Create() 
        {
            ContentDefinitionManager.AlterTypeDefinition("LoginWidget", type => type
                .WithPart(typeof(LoginWidgetPart).Name)
                .WithPart("WidgetPart")
                .WithPart(typeof(CommonPart).Name)
                .WithSetting("Stereotype", "Widget")
                );

            ContentDefinitionManager.AlterTypeDefinition("ModalLoginWidget", type => type
                .WithPart(typeof(ModalLoginWidgetPart).Name)
                .WithPart("WidgetPart")
                .WithPart(typeof(CommonPart).Name)
                .WithSetting("Stereotype", "Widget")
                );

            ContentDefinitionManager.AlterTypeDefinition("PopboxLoginWidget", type => type
                .WithPart(typeof(PopboxLoginWidgetPart).Name)
                .WithPart("WidgetPart")
                .WithPart(typeof(CommonPart).Name)
                .WithSetting("Stereotype", "Widget")
                );

            return 1;
        }
    }
}